<?php

class Curso{
	
	public $bd;
	public $resultado;

	
	public function __construct(){
		
		$this->bd = new Basedatos();
		
	}
		public function mostrar_curso(){
		
		$query = "CALL ConsultarTodosCurso()";
		$this->result = $this->bd->select($query);
		return $this->result;		
	}
		public function nota_curso($curso, $asignatura){
			$query = "CALL ConsultarNotaCursoAsignatura('$curso', '$asignatura')";
			$this->result = $this->bd->select($query);
			return $this->result;		
	}
		public function nota_alumno_asig($rut, $asignatura){
			$query = "CALL ConsultarNotasAlumnoAsignatura('$rut', '$asignatura')";
			$this->result = $this->bd->select($query);
			return $this->result;		
	}
		public function ingresar_curso($nivel, $letra){
		
		$query = "CALL IngresarCurso('".$nivel."', '".$letra."')";
		$this->result = $this->bd->insert($query);		
	}
		public function editar_curso($id, $nivel, $letra){
			$query = "CALL ModificarCurso('".$id."', '".$nivel."', '".$letra."')";
			$this->result = $this->bd->update($query);	
		}
		public function eliminar_curso($id){
			$query = "CALL EliminarCurso('".$id."')";
			$this->result = $this->bd->delete($query);	
		}
		public function mostrar_curso_uno($id){
			$query = "CALL ConsultarUnCurso('".$id."')";
			$this->result = $this->bd->select($query);
			return $this->result;
		}
		public function mostrar_curso_id($id){
			$query = "CALL ConsultarCursoId('".$id."')";
			$this->result = $this->bd->select($query);
			return $this->result;
		}
		public function existe_curso($nivel, $letra){
			$query = "CALL ExisteCurso('".$letra."', '".$nivel."')";
			$this->result = $this->bd->select($query);
			$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}
		public function relacion_curso_alumno($id){
			$query = "CALL RelCursoUsuario('".$id."')";
			$this->result = $this->bd->select($query);
			$row=mysql_fetch_array($this->result);
			if ($row['contador'] > 0){
				$res = true;
			}else{
				$res = false;
			}
			return $res;

		}	
}
?>